﻿namespace AliDDNS.Configuration;

public enum RecordType
{
    A,
    NS,
    MX,
    TXT,
    CNAME,
    SRV,
    AAAA,
    CAA,
    REDIRECT_URLM,
    FORWARD_URL
}
public class DDNSConfig
{
    private RecordType _type;
    private double _interval = 60;
    public string? Lang { get; set; } = "zh";
    public string? UserClientIp { get; set; }
    public required string DomainName { get; set; }
    public required string RR { get; set; }
    public required string Type
    {
        get => _type.ToString( );
        set
        {
            if (!Enum.TryParse(value, out _type))
                throw new ArgumentException("无效的记录类型枚举值");
        }
    }
    public long? TTL { get; set; }
    public long? Priority { get; set; }
    public string Line { get; set; } = "default";
    public double Interval
    {
        get => _interval;
        set
        {
            if (value <= 0)
                throw new ArgumentException("间隔时间必须大于等于0");
            _interval = value;
        }
    }
}
